/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package com.plian.system.controller.fr.bank;

import com.plian.Tools.base.BaseController;
import com.plian.system.dto.fr.bank.BankCurrentHistoryDTO;
import com.plian.system.model.CommonCode;
import com.plian.system.model.R;
import com.plian.system.service.fr.bank.IBankCurrentHistoryService;
import com.plian.system.service.sys.orgzation.OrgzationService;
import com.plian.system.vo.report.PieChartVO;
import com.plian.system.wrapper.fr.bank.BankCurrentHistoryWrapper;
import lombok.AllArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 控制器
 *
 * @author
 * @since 2020-07-17
 */
@RestController
@AllArgsConstructor
@RequestMapping("api/bankcurrenthistory")
public class BankCurrentHistoryController extends BaseController {

	private static final Logger log = LoggerFactory.getLogger(BankCurrentHistoryController.class);

	private IBankCurrentHistoryService bankCurrentHistoryService;

	private OrgzationService orgzationService;

	private BankCurrentHistoryWrapper bankCurrentHistoryWrapper;

//	/** TODO DEL
//	 * 详情
//	 */
//	@PostMapping("/detail")
//	public R<BankCurrentHistoryVO> detail(@RequestBody BankCurrentHistory bankCurrentHistory) {
//		BankCurrentHistory detail = bankCurrentHistoryService.getOne(Condition.getQueryWrapper(bankCurrentHistory));
//		R<BankCurrentHistoryVO> objResult = new R<>(CommonCode.SUCCESS);
//		BankCurrentHistoryVO bankCurrentHistoryVO = bankCurrentHistoryWrapper.entityToVO(detail);
//		objResult.setPageData(bankCurrentHistoryVO);
//		return objResult;
//	}
//
//	/**
//	 * 分页
//	 */
//	@PostMapping("/list")
//	@PassToken
//	public ListResult<BankCurrentHistoryVO> list(@RequestBody Query query) {
//		List<SearchEntity> entityList = query.getSearch();
//		if (query.getAscs()==null&&query.getDescs()==null){
//			query.setDescs("create_time");
//		}
//		QueryWrapper<BankCurrentHistory> queryWrapper = SearchParamEntiy.getQueryWrapper(
//				Condition.getQueryWrapper(new BankCurrentHistory()), entityList
//		);
//		TokenSearch<BankCurrentHistory> tokenSearch = new TokenSearch<>();
//		tokenSearch.addTokenQuery(queryWrapper, query);
//		IPage<BankCurrentHistory> pages = bankCurrentHistoryService.page(Condition.getPage(query), queryWrapper);
//		List<BankCurrentHistoryVO> projectInfoVOS = bankCurrentHistoryWrapper.entityToVO(pages.getRecords());
//		ListResult<BankCurrentHistoryVO> listResult = new ListResult<>(CommonCode.SUCCESS);
//		listResult.setList(projectInfoVOS);
//		listResult.setTotal(Long.valueOf(pages.getTotal()).intValue());
//		return listResult;
//	}
//
//	/**
//	 * 新增或修改
//	 */
//	@PostMapping("/submit")
//	@Resubmit(delaySeconds = 0)
//	public R submit(@Valid @RequestBody BankCurrentHistory bankCurrentHistory) {
//		return bankCurrentHistoryService.saveOrUpdate(bankCurrentHistory)
//				? new R(CommonCode.SUCCESS) : new R(CommonCode.FAIL);
//
//	}
//
//	/**
//	 * 删除
//	 */
//	@PostMapping("/remove")
//	public R remove(@RequestBody PageData pd) {
//		List<String> ids = (List<String>)pd.get("ids");
//		return bankCurrentHistoryService.deleteLogic(Func.toLongList(StringUtils.join(ids, StringPool.COMMA)))
//				? new R(CommonCode.SUCCESS) : new R(CommonCode.FAIL);
//	}
//
//	/**
//	 * 存款余额表格统计
//	 * @param bankCurrentHistoryDTO
//	 * @return
//	 */
//	@PostMapping("/depositBalance/statistics")
//	public R<ReportReturnVO> dStatistics(@Valid @RequestBody(required = false) BankCurrentHistoryDTO bankCurrentHistoryDTO) {
//		R<ReportReturnVO> result = new R<>(CommonCode.SUCCESS);
//		result.setPageData(bankCurrentHistoryService.dStatistics(bankCurrentHistoryDTO));
//		return result;
//	}

	/**
	 * 存款余额分布
	 * @param bankCurrentHistoryDTO
	 * @return
	 */
	@PostMapping("/depositBalance/distribution")
	public R<PieChartVO> distribution(@Valid @RequestBody(required = false) BankCurrentHistoryDTO bankCurrentHistoryDTO) {
		R<PieChartVO> result = new R<>(CommonCode.SUCCESS);
		result.setPageData(bankCurrentHistoryService.distribution(bankCurrentHistoryDTO));
		return result;
	}

	/**
	 * 存款余额占比
	 * @param bankCurrentHistoryDTO
	 * @return
	 */
	@PostMapping("/depositBalance/proportion")
	public R<PieChartVO> proportion(@Valid @RequestBody(required = false) BankCurrentHistoryDTO bankCurrentHistoryDTO) {
		R<PieChartVO> result = new R<>(CommonCode.SUCCESS);
		result.setPageData(bankCurrentHistoryService.proportion(bankCurrentHistoryDTO));
		return result;
	}

//	/**
//	 * 开户情况统计
//	 * @param bankCurrentHistoryDTO
//	 * @return
//	 */
//	@PostMapping("/openAccount/statistics")
//	public R<ChartsVO> statistics(@Valid @RequestBody(required = false) BankCurrentHistoryDTO bankCurrentHistoryDTO) {
//		R<ChartsVO> result = new R<>(CommonCode.SUCCESS);
//		result.setPageData(bankCurrentHistoryService.kStatistics(bankCurrentHistoryDTO));
//		return result;
//	}
//
//	/**
//	 * 存款月度环比
//	 * @param bankCurrentHistoryDTO
//	 * @return
//	 */
//	@PostMapping("/deposit/monthOnMonth")
//	public R<ChartsVO> monthOnMonth(@Valid @RequestBody(required = false) BankCurrentHistoryDTO bankCurrentHistoryDTO) {
//		R<ChartsVO> result = new R<>(CommonCode.SUCCESS);
//		result.setPageData(bankCurrentHistoryService.monthOnMonth(bankCurrentHistoryDTO));
//		return result;
//	}
//
//	/**
//	 * 存款结构表格统计
//	 * @param bankCurrentHistoryDTO
//	 * @return
//	 */
//	@PostMapping("/depositStructure/statistics")
//	public R<ReportReturnVO> structureStatistics(@RequestBody BankCurrentHistoryDTO bankCurrentHistoryDTO) {
//		R<ReportReturnVO> result = new R<>(CommonCode.SUCCESS);
//		result.setPageData(bankCurrentHistoryService.structureStatistics(bankCurrentHistoryDTO));
//		return result;
//	}
//
//	/**
//	 * 存款余额分布
//	 * @param bankCurrentHistoryDTO
//	 * @return
//	 */
//	@PostMapping("/depositStructure/distribution")
//	public R<PieChartVO> structureDistribution(@RequestBody BankCurrentHistoryDTO bankCurrentHistoryDTO) {
//		R<PieChartVO> result = new R<>(CommonCode.SUCCESS);
//		result.setPageData(bankCurrentHistoryService.structureDistribution(bankCurrentHistoryDTO));
//		return result;
//	}
//
//	/**
//	 * 结构性存款金额
//	 * @param bankCurrentHistoryDTO
//	 * @return
//	 */
//	@PostMapping("/depositStructure/company")
//	public R<PieChartVO> structureCompany(@RequestBody BankCurrentHistoryDTO bankCurrentHistoryDTO) {
//		R<PieChartVO> result = new R<>(CommonCode.SUCCESS);
//		result.setPageData(bankCurrentHistoryService.structureCompany(bankCurrentHistoryDTO));
//		return result;
//	}
//
//	/**
//	 * 市属国有企业银行账户及存贷款汇总
//	 * @param pd
//	 * @return
//	 */
//	@PostMapping("/bankAccountAndDepositLoan")
//	public  ListResult<PageData> bankAccountAndDepositLoan(@RequestBody PageData pd){
//		return  bankCurrentHistoryService.getBankAccountAndDepositLoan(pd);
//	}
//
//	/**
//	 * 企业存款借款汇总
//	 * @param pd
//	 * @return
//	 */
//	@PostMapping("/summaryDepositsLoan")
//	public  R<PageData> summaryDepositsLoans(@RequestBody PageData pd){
//		return  bankCurrentHistoryService.getSummarydepositsloans(pd);
//	}
//
//	/**
//	 * 返回银行资金企业汇总信息
//	 * @param pd
//	 * @return
//	 */
//	@PostMapping("/companySummary")
//	ListResult<PageData> getCompanySummary(@RequestBody PageData pd){
//		return bankCurrentHistoryService.getCompanySummary(pd);
//	}

}

